﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _03.RecursiveDFS
{
    class Graph
    {
        private List<int>[] childNodes;

        public Graph(List<int>[] childNodes)
        {
            this.childNodes = childNodes;
        }

        public int NodesCount
        {
            get { return childNodes.Length; }
        }

        public void RecursiveDFS(int node, bool[] visited)
        {
            if (!visited[node])
            {
                visited[node] = true;
                Console.WriteLine("Visited node {0}", node);
                foreach (var childNode in this.childNodes[node])
                {
                    RecursiveDFS(childNode, visited);
                }
            }
        }
    }
}
